package cn.wit.tech.controller;

import cn.wit.utils.pojo.TechPoint;
import cn.wit.tech.service.TechPointService;
import cn.wit.utils.response.Result;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/tech/techPoint")
@CrossOrigin
@Api(tags = "技术点")
public class TechPointController {
    private Logger logger = LoggerFactory.getLogger(TechPointController.class);

    @Autowired
    private TechPointService techPointService;

    @PostMapping("/insertTechPoint")
    @ApiOperation("技术点新增")
    public Result insertTechPoint(@RequestBody TechPoint techPoint){
            return this.techPointService.insert(techPoint);
    }

    @PostMapping("/deleteByIdTechPoint")
    @ApiOperation("技术点删除")
    public Result deleteByIdTechPoint(int id){
            return this.techPointService.deleteById(id);
    }

    @PostMapping("/updateByIdTechPoint")
    @ApiOperation("技术点更新")
    public Result updateByIdTechPoint(@RequestBody TechPoint techPoint){
            return this.techPointService.updateById(techPoint);
    }

    @GetMapping("/selectAllTechPoint")
    @ApiOperation("查询所有技术点")
    public Result selectAllTechPoint(){
            return this.techPointService.selectAllTechPoint();
    }

    @GetMapping("/selectTechTechPointAllPage/{num}/{size}")
    @ApiOperation("分页查询所有技术点")
    public Result selectTechTechPointAllPage(@PathVariable("num") int num,
                                             @PathVariable("size") int size){
        IPage<TechPoint> page=new Page<>(num,size);
            return this.techPointService.selectAllPage(page);
    }
}
